package com.neusoft.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.bean.T_menu;
import com.neusoft.bean.T_order;
import com.neusoft.bean.T_order_menu;
import com.neusoft.bean.T_order_table;
import com.neusoft.dao.T_orderDao;
import com.neusoft.service.T_orderService;
@Service("T_orderService")
@Transactional
public class T_orderServiceImpl implements T_orderService{
	@Autowired
	public T_orderDao t_orderDao;
	@Override
	public List<T_order> showOrder() {
		// TODO Auto-generated method stub
		return t_orderDao.showOrder();
	}
	@Override
	public List<T_order> sumMoney(int tableNum) {
		double sum=0;
		List<T_order> list1 = t_orderDao.showOrderByTable(tableNum);
		List<T_order_menu> list2 = null;
		for (T_order order : list1) {
			list2 = t_orderDao.showOrderMenu(order.getOrderNum());
			for (T_order_menu menu1 : list2) {
				T_menu menu2 = t_orderDao.showMenu(menu1.getMenuId());
				sum+=menu2.getPrice()*menu1.getNum();
			}
		}
		for (T_order order : list1) {	
			order.setTotal((float)sum);		
		}
		list1= t_orderDao.showOrderByTable(tableNum);
		return list1;
	}
	public T_order showOrderById(int id){
		
		return t_orderDao.showOrderById(id);
	}
	@Override
	public T_order_table showTest(int id) {
		
		return t_orderDao.showTest(id);
	}
	@Override
	public Map<String, Object> showTest1(int id) {
		
		return t_orderDao.showTest1(id);
	}
	@Override
	public List<T_order_table> showTest2(int id) {
		
		return t_orderDao.showTest2(id);
	}
	
}
